package com.simple.portal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.simple.base.dao.BaseDAO;
import com.simple.portal.dao.IApplicationApplyDAO;
import com.simple.portal.vo.ApplicationApplyVO;
import com.simple.util.common.Constants;

@Repository("applicationApplyDAO")
public class ApplicationApplyDAOImpl extends BaseDAO implements IApplicationApplyDAO {

	@Override
	public ApplicationApplyVO findById(final String id) {
		return  super.get(ApplicationApplyVO.class,id);
	}

	@Override
	public void save(final ApplicationApplyVO applicationApplyVO,final String operator) {
		ApplicationApplyVO tempApplicationApplyVO = super.save(applicationApplyVO);
		super.saveLogger(operator, tempApplicationApplyVO, tempApplicationApplyVO.getApplicationApplyId(),Constants.LOGGER_OPERATE_FLAG_ADD);

	}

	@Override
	public void update(final ApplicationApplyVO applicationApplyVO,final String type,final String operator) {
		super.update(applicationApplyVO);
		super.saveLogger(operator, applicationApplyVO, applicationApplyVO.getApplicationApplyId(),type);

	}
	
	@Override
	public List<ApplicationApplyVO> findAll() {
		return super.query(ApplicationApplyVO.class);
	}

	@Override
	public void delete(final ApplicationApplyVO applicationApplyVO,final String operator) {
		super.delete(applicationApplyVO);
		super.saveLogger(operator, applicationApplyVO, applicationApplyVO.getApplicationApplyId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

	@Override
	public void delete(final String id,final String operator) {
		ApplicationApplyVO applicationApplyVO = findById(id);
		super.delete(ApplicationApplyVO.class,id);
		super.saveLogger(operator, applicationApplyVO, applicationApplyVO.getApplicationApplyId(), Constants.LOGGER_OPERATE_FLAG_DELETE);
	}

}
